﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace Project_1_refactored_
{
    enum weaponStates
    {
        Active,
        inActive
    }

    class Weapon : GameObject
    {
        #region Declaration
        const int MAX_DISTANCE = 1000; //The distance at which dagger became inactive

        Vector2 wStartPosition; //starting possition
        Vector2 wSpeed; //speed on which it moves
        Vector2 wDirection; //direction, how much px per fps

        //To make it dissapear once it collides with enemy
        weaponStates weaponState = weaponStates.inActive;
        public weaponStates WeaponState
        {
            get { return weaponState; }
        }
        #endregion

        #region Contstructor
        public Weapon()
        {
            weaponState = weaponStates.Active;
            Animated = true;
        }
        #endregion

        #region LoadContent, Update, Draw methods
        public void LoadContent(ContentManager Content)
        {
            base.LoadContent(Content, @"Weapon\dagger_01", "", "", "","", new int[] { 1, 1, 1, 1, 1 });
        }

        public void Update(GameTime gameTime)
        {
            if (Vector2.Distance(wStartPosition, v2Position) > MAX_DISTANCE) //pass in a starting vector2 and an ending vector2
                deActivate();

                if (weaponState == weaponStates.Active)
                    base.Update(gameTime, wSpeed, wDirection);
        }

        public new void Draw(SpriteBatch spriteBatch)
        {
            if (weaponState == weaponStates.Active)
                base.Draw(spriteBatch);
        }
        #endregion

        #region helper methods
        //to start dager motion
        public void throwDagger(Vector2 startposition, Vector2 speed, Vector2 direction)
        {
            v2Position = startposition;
            wStartPosition = startposition;
            wSpeed = speed;
            wDirection = direction;
            weaponState = weaponStates.Active;
        }


        //deActive and Active in order to make dagger dissapear after collision
        public void deActivate()
        {
            weaponState = weaponStates.inActive;
        }

        public bool Active()
        {
            if (WeaponState == weaponStates.Active)
                return true;
            else
                return false;
        }
        #endregion
    }
}
